{extend name="base/common"}

{block name="style"}
<style>
    .shadow{width: 100%;height: 100%;position: absolute;left: 0;top: 0;background: rgba(0,0,0,0.4);z-index: 88;}
</style>
{/block}

{block name="page-header"}
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>购物商城</h2>
        <ol class="breadcrumb">
            <li>
                订单管理
            </li>
            <li class="active">
                <strong><a href="{:Url('Order/index')}">列表页</a></strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">
    </div>
</div>
{/block}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>订单列表</h5>
                    <div class="ibox-tools">
                        <!--<a data-toggle="modal" class="btn btn-sm btn-primary" href="{:Url('Order/add')}">添加</a>-->
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th><input class="i-checks check-all" type="checkbox"></th>
                                <th>订单编号</th>
                                <th>下单人 </th>
                                <th>创建时间</th>
                                <th>状态</th>
                                <th>是否出货</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="vo"}
                            <tr data-id="{$vo.id}">
                                <td><input type="checkbox" class="i-checks" name="input[]"></td>
                                <td>{$vo.id}</td>
                                <td>{$vo.create_user}</td>
                                <td>{$vo.create_time}</td>
                                <td>{$vo.status_text}</td>

                                {if condition="($vo['shipment'] == 0)"}
                                <td><a data-toggle="modal" class="btn btn-sm btn-primary shipment">未出货</a></td>
                                {else /}
                                <td><a data-toggle="modal" class="btn btn-sm btn-primary" disabled="disabled">已出货</a></td>
                                {/if}

                                <td>
                                    <!--<a href="{:Url('Order/edit?id='.$vo['id'])}">修改</a>-->
                                    <!--&emsp;<a href="{:Url('Order/del?id='.$vo['id'])}" class="confirm ajax-del">删除</a>-->
                                    <a href="{:Url('Order/preview?id='.$vo['id'])}">预览</a>
                                </td>
                            </tr>
                            {/volist}
                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="10">
                                    <div class="page">{$_page}</div>
                                </td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<iframe id="iframe" src="" style="height: 80%;width: 392px;z-index: 99;position: absolute;top: 10%;border: 0;left: 32%;background: #fff;display: none;" scrolling="auto" seamless></iframe>
<div class="shadow" style="display: none"></div>
{/block}

{block name="script"}
<script src="/admin/js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(document).ready(function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });

    $("tbody tr").on("click",".shipment",function () {
        var this_ = $(this);
        var id = $(this).parents("tr").attr("data-id");
        swal({
            title: "",
            text: "是否确定出货?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            cancelButtonText: "取消",
            confirmButtonText: "确定",
            closeOnConfirm: false
        },
        function(){
            swal({
                title: "",
                text: "出货成功",
                type: "success",
                timer: 1500
            });
            setTimeout(function () {
                $.ajax({
                    url: "{:Url('Order/shipment')}",
                    data: {
                        shipment: 1,
                        id: id
                    },
                    type: "post",
                    success: function (data) {
                        this_.attr("disabled","disabled");
                        this_.click(false);
                        this_.html("已出货");
                    }
                })
            },1500);
        });
    });

</script>
{/block}